<?php
    use User\Model\LpicModel;
?>
<!-- page heading start-->
<div class="page-heading">
    <h3>
        <a href="/User/Lpic/index">直播列表</a>->菜单列表
    </h3>

</div>
<!-- page heading end-->
<div class="row">
    <div class="col-sm-12">
        <section class="panel">
            <header class="panel-heading">
                <a class="btn btn-default" href="<?php echo '/User/Lpic/itemUpdate?liveId=' . I('get.id', '', '');?>">增加</a>
            </header>
            <div class="panel-body">
                <input type="hidden" value="<?php echo I('get.id', '', '');?>" id="liveId">
                <table class="table table-hover general-table table-bordered">
                    <thead>
                    <tr>
                        <th width="12%">专题名称</th>
                        <th width="25%">专题描述</th>
                        <th width="20%">创建时间</th>
                        <th width="15%">排序</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <?php foreach($list as $val){?>
                    <tr>
                        <td>
                            <span style="word-break:break-all;word-wrap:break-word;">
                                <?php echo $val['name'];?>
                            </span>
                        </td>
                        <td>
                            <span style="word-break:break-all;word-wrap:break-word;">
                                <?php
                                echo $val['describe'];
                                ?>
                            </span>
                        </td>
                        <td>
                            <span>
                                <?php echo $val['added_date'];?>
                            </span>
                        </td>
                        <td>
                            <span>
                                <img src='/Public/images/arrow_up.png' style='margin-left:30px;width: 25px;height: 50px;' onclick='change_up(this)'
                                     data-id="<?php echo $val[item_id];?>">
                                <img src='/Public/images/arrow_down.png' style='margin-left:20px;width: 25px;height: 50px;;' onclick='change_down(this)'
                                     data-id="<?php echo $val[item_id];?>">
                            </span>
                        </td>
                        <td>
                            <div>
                                <a class="btn btn-success"
                                   href="<?php echo '/User/Lpic/itemUpdate?type=update&liveId=' . $val['live_id'] . '&itemId=' . $val['item_id'];?>">编辑
                                <a class="btn btn-default" style="margin-left: 10px;"
                                   href="<?php echo '/User/Lpic/itemPicUpdate?type=update&liveId=' . $val['live_id'] . '&itemId=' . $val['item_id'];?>">图集</a>
                                <a class="btn btn-danger" href="#" style="margin-left: 10px;"
                                   onclick="<?php echo 'return delete_data(' . $val['item_id'] .')';?>">删除</a>
                            </div>
                        </td>
                    </tr>
                    <?php }?>

                    </tbody>
                </table>
                <div class="pages">
                    {$page}
                </div>
            </div>
        </section>
    </div>
</div>
<script>
    function delete_data(id){
        $.ajax({
            data:{itemId:id},
            dataType:'json',
            url:'/User/Lpic/itemDelete',
            type:'get',
            success:function(res){
                window.location.reload();
            }
        });
        return false;
    }
    function change_up(p){
        var live_id = $("#liveId").val();
        var id = $(p).attr("data-id");
        $.ajax({
            data:{itemId:id, liveId:live_id},
            dataType:'json',
            url:'/User/lpic/itemPriorityDec',
            type:'get',
            success:function(res){
                window.location.reload();
            }
        })
    }
    function change_down(p){
        var live_id = $("#liveId").val();
        var id = $(p).attr("data-id");
        $.ajax({
            data:{itemId:id, liveId:live_id},
            dataType:'json',
            url:'/User/lpic/itemPriorityInc',
            type:'get',
            success:function(res){
                window.location.reload();
            }
        })
    }
</script>